package com.example.jvm.jvm06.lesson52;

import lombok.extern.slf4j.Slf4j;

/**
 * @Description
 * @Date 2021/7/15
 * @Created by Jonathan
 */
@Slf4j
public class Test {
    private static final int _1MB = 1024 * 1024;
    /*
    -verbose:gc
    -Xmx200M
    -Xmn50M
    -XX:+PrintTenuringDistribution
    -XX:+PrintGCDetails
    -XX:+PrintHeapAtGC
    -XX:+UseParNewGC
    -XX:+MaxTenTenuringThreshold=3


     */

    public static void main(String[] args) {
        byte[] allocation1 = new byte[2 * _1MB];
        youngGc(1, 40);
        youngGc(2, 40);
        youngGc(3, 40);
        youngGc(4, 40);
    }

    private static void youngGc(int n, int m) {
        log.info("发生第：{}次youngGc", n);
        for (int i = 0; i < m; i++) {
            byte[] bytes = new byte[_1MB];
        }
    }
}
